//
//  WebViewController.m
//  VmiSJ
//
//  Created by 汪的一声就哭了！ on 2017/1/16.
//  Copyright © 2017年 汪的一声就哭了！. All rights reserved.
//

#import "WebViewController.h"

@interface WebViewController ()<UIWebViewDelegate>
@property (nonatomic, strong) UIWebView *webView;
@end

@implementation WebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [PTSProgressHUD show];
    self.title = self.titleStr;
    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-64)];
    [self.view addSubview:self.webView];
    if ([self.titleStr isEqualToString:@"预览详情"]) {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 30)];
        label.backgroundColor = [UIColor colorWithRed:255.0/255.0 green:187.0/255.0 blue:0 alpha:1];
        label.text = @"本页为预览信息图片，不具备功能，无法点击";
        [self.view addSubview:label];
        label.font = [UIFont systemFontOfSize:13];
        label.textAlignment = NSTextAlignmentCenter;
        label.textColor = [UIColor colorWithRed:95.0/255.0 green:96.0/255.0 blue:98.0/255.0 alpha:1];
        self.webView.frame = CGRectMake(0, 20, WIDTH, HEIGHT-94);
    }
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]];
    self.webView.delegate = self;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [self.webView addGestureRecognizer:tap];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [PTSProgressHUD hide];
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSString *url = [NSString stringWithFormat:@"%@",[request URL]];
    if ([url isEqualToString:@"weimiapp://"] || [url containsString:@"http://www.vmijob.com/Home/Share/hongbao"]) {
        return NO;
    }
    return YES;
}

- (void)tapAction:(UITapGestureRecognizer *)tap
{
    NSLog(@"点你妹");
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
